package com.xuhuan.practice.config;

import com.xuhuan.practice.properties.OSSMinioProperties;
import com.xuhuan.practice.utils.SpringContextUtil;
import io.minio.MinioClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: huan.xu
 * @create: 2023/12/23 15:20
 * @description:
 **/
@Configuration
public class MinioConfig {

  @Bean
  public MinioClient minioClient() {
    OSSMinioProperties ossMinioProperties = SpringContextUtil.getBean(OSSMinioProperties.class);
    return new MinioClient(
        ossMinioProperties.getMinioEndpoint(),
        Integer.valueOf(ossMinioProperties.getMinioPort()),
        ossMinioProperties.getMinioAccessKey(),
        ossMinioProperties.getMinioSecretKey(),
        ossMinioProperties.getMinioSecure()
    );
  }
}
